package atm;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class Test {
    public void copy(String source,String dist) {
        FileInputStream fis = null;
        try {
            int n = 0;
            byte[] bt = new byte[1024];
            fis = new FileInputStream(source);
            while ((n = fis.read(bt)) != -1){
                FileOutputStream fos = null;
                fos = new FileOutputStream(dist);
                fos.write(bt,0,n);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if (fis != null){
                try {
                    fis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    public static void main(String[] args) {
        Test test = new Test();
        test.copy("2.txt","3.txt");
    }
}
